package com.nba.dao.impl;

import java.util.Date;
import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import com.nba.bean.Video;
import com.nba.dao.VideoDao;
import com.nba.util.DBUtil;

public class VideoDaoImpl implements VideoDao {
		
	JdbcTemplate jt = new JdbcTemplate(DBUtil.getDataSource());
	
	@Override
	public List<Video> selectVideoAll() {
		String sql = "SELECT * FROM video";
		List<Video> list = jt.query(sql, new BeanPropertyRowMapper<Video>(Video.class));
		return list;
	}

	@Override
	public int insertVideo(String videoTheme, String videoContent, String videoUrl, Date videoTime, int typeId) {
		String sql = "INSERT INTO video(video_theme , video_content , video_url , video_time,type_id) Value(?,?,?,?,?)";
		return jt.update(sql,videoTheme, videoContent, videoUrl, videoTime, typeId);
	}

}
